const fs = require('fs')

function write(){
    console.log('write begin!')

    let text = 'Hello Node!'
    fs.writeFile('writeDemo.txt',text,function(err){
        if(err){
            console.log(err)
        }else{
            console.log('ok!')
        }
    })

    console.log('write end!')
}

function read(){
  console.log('read begin!')

  fs.readFile('writeDemo.txt','utf-8',function(err,data){
      if(err){
          console.log(err)
      }else{
          console.log(data)
      }
  })

  console.log('read end!')
}

module.exports = {
    write : write,
    read : read
}